export function getLegend() {
  return {
    // icon: "rect",
    icon: "circle",
    // itemHeight: 21, //图例图标的高度
    // itemWidth: 26, //图例图标的宽度
    textStyle: {
      //图例文字的样式
      color: "#000",
      fontSize: 18,
    },
    type: "scroll",
    orient: "vertical",
    right: 10,
    top: 20,
    bottom: 20,
    formatter: (name) => {
      if (!name) return "";
      return LineFeedLabel(name, 18); // 根据你的需求修改参数
    },
  };
}

function LineFeedLabel(data, length) {
  //data 要处理的字符串
  //length 每行显示长度
  let word = "";
  let num = Math.ceil(data.length / length); // 向上取整数
  // 一行展示length个
  if (num > 1) {
    for (let i = 1; i <= num; i++) {
      word += data.substr((i - 1) * length, length);
      if (i < num) {
        word += "\n";
      }
    }
  } else {
    word += data.substr(0, length);
  }
  return word;
}
